package pri.damai.xiaowu.order.server.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pri.damai.xiaowu.common.core.form.IdForm;
import pri.damai.xiaowu.common.core.vo.ResultVO;
import pri.damai.xiaowu.order.common.dto.CreateOrderDTO;
import pri.damai.xiaowu.order.server.entity.OdrOrder;
import pri.damai.xiaowu.order.server.service.impl.OdrOrderServiceImpl;

import javax.annotation.Resource;

/**
 * 订单表(OdrOrder)表控制层
 *
 * @author makejava
 * @since 2022-04-28 21:39:42
 */
@RestController
@RequestMapping("odrOrder")
public class OdrOrderController {
    /**
     * 服务对象
     */
    @Resource
    OdrOrderServiceImpl odrOrderService;

    @PostMapping("/createOrder")
    public ResultVO<Void> createOrder(@RequestBody CreateOrderDTO createOrderDTO) {
        odrOrderService.createOrder(createOrderDTO);
        return ResultVO.success();
    }

    @PostMapping("/deleteById")
    public ResultVO<Void> deleteOrder(@RequestBody IdForm idForm) {
        odrOrderService.removeById(idForm.getId());
        return ResultVO.success();
    }

    @PostMapping("/getOrderById")
    public ResultVO<OdrOrder> getOrderById(@RequestBody IdForm idForm) {
        return ResultVO.success(odrOrderService.getById(idForm.getId()));
    }
}

